/**
 * 
 */
package jobs.poc.writables;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;

/**
 * @author zvikadori
 *
 */
public class WordPairDecadeTimes implements Writable{
	
	private String firstWord;
	private String secondWord;
	private int decade;
	private long times;
	
	

	public String getFirstWord() {
		return firstWord;
	}

	public void setFirstWord(String firstWord) {
		this.firstWord = firstWord;
	}

	public String getSecondWord() {
		return secondWord;
	}

	public void setSecondWord(String secondWord) {
		this.secondWord = secondWord;
	}

	public int getDecade() {
		return decade;
	}

	public void setDecade(int decade) {
		this.decade = decade;
	}
	
	public long getTimes() {
		return times;
	}

	public void setTimes(long times) {
		this.times = times;
	}

	public void readFields(DataInput in) throws IOException {
//		firstWord = in.read
	}

	public void write(DataOutput arg0) throws IOException {
		// TODO Auto-generated method stub
		
	}
	
	@Override
	public String toString(){
		String ans = firstWord + " " + secondWord + " " + decade + " " + times;
		return ans;
	}
	
	public static WordPairDecadeTimes fromString(Text line){
		WordPairDecadeTimes ans = null;
		String[] splits = line.toString().split(" |\t");
//		if (splits.length == 9){
			ans = new WordPairDecadeTimes();
			ans.setFirstWord(splits[0]);
			ans.setSecondWord(splits[1]);
			ans.setDecade(Integer.parseInt(splits[splits.length - 4]));
			ans.setTimes(Long.parseLong(splits[splits.length -3]));

//		}
//		else {
//			System.out.println();
//		}
		return ans;
	}
	
	

}
